<!--
 * @FilePath: /fxfzywpt/src/views/uncertain/geologicalDisaster1.vue
 * @Description: 
-->
<template>
  <div class="app-container">
    <!-- 公共顶部 -->
    <large-screen-header />
    <!-- 主体部分 -->
    <div class="app-main">
      <!-- 左侧 -->
      <div class="app-left">
        <div class="app-left-total">
          全国设定地震个数
          <span>
            <i v-for="item in totalArr" :key="item">{{ item }}</i>
          </span>
        </div>
        <div class="app-left-item">
          <!-- 次级标题 -->
          <!-- <subheadings :name="'各省（直辖市）设定地震个数统计'" /> -->
          <!-- <CollapsibleTable :name="'各省（直辖市）设定地震个数统计'" /> -->
        </div>
        <div class="app-left-item">
          <subheadings :name="'自2015年以来破坏性地震验证情况统计'" />
          <earthquake />
        </div>
        <div class="app-left-item">
          <subheadings :name="'设定地震个数增长趋势图'" />
          <ColumnLineChart />
        </div>
      </div>
      <!-- 中心部分 -->
      <div class="app-center">
        <!-- 标题 -->
        <headline :name="'全国设定地震灾害损失分布图'" />
        <!-- 地图 -->
        <div class="app-map">
          <!-- <IndexMap></IndexMap> -->
          <OlMap :refId="'geologicaldisaster'" style="height: 100%" @getMap="getMap"></OlMap>
        </div>
      </div>
      <!-- 右侧 -->
      <div class="app-right">
        <div class="app-right-item">
          <subheadings :name="'设定地震灾害损失评估成果'" />
          <LossAssessment />
        </div>
        <div class="app-right-item">
          <subheadings :name="'现场抽样复核情况'" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup name="Index">
import earthquake from '@/views/disasterLosses/components/earthquake.vue';
import ColumnLineChart from '@/views/disasterLosses/components/ColumnLineChart.vue';
// import CollapsibleTable from '@/views/disasterLosses/components/CollapsibleTable.vue';
import LossAssessment from '@/views/disasterLosses/components/LossAssessment.vue';
import OlMap from '@/components/Olmap';
import { Style, Circle as CircleStyle, Fill, Stroke, Icon } from 'ol/style';
import Feature from 'ol/Feature';
import { Point } from 'ol/geom';
import { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer';
import { OSM, Vector as VectorSource } from 'ol/source';
// start
import Text from 'ol/style/Text';
import yellowMarkerImg from '@/assets/map/image/newImage/yelloMarker.png';
// end

// 地震个数统计
let totalNum = '1024';
const totalArr = ref([]);

totalArr.value = Array.from(totalNum);
// start
const tableData = [];
for (let i = 0; i < 10; i++) {
  tableData.push({
    level: i + 1,
    lost: +i,
    time: '2021-08-08',
  });
}
const mapInstance = ref(null);
const vectorLayer = ref(null);

const getMap = (map) => {
  mapInstance.value = map.value;
  //   假数据
  createVectorLayer();
  addRandomPoints();
};
const createVectorLayer = () => {
  vectorLayer.value = new VectorLayer({
    source: new VectorSource(),
    zIndex: 2,
  });
  mapInstance.value.addLayer(vectorLayer.value);
};
const addRandomPoints = () => {
  if (!vectorLayer.value) {
    return;
  }
  const province = { lonMin: 100, lonMax: 140, latMin: 15, latMax: 50 }; // 扩大的中国范围

  for (let i = 0; i < 10; i++) {
    const lon = Math.random() * (province.lonMax - province.lonMin) + province.lonMin;
    const lat = Math.random() * (province.latMax - province.latMin) + province.latMin;
    const number = Math.floor(Math.random() * 100); // 随机数字

    const point = new Feature({
      geometry: new Point([lon, lat]),
    });

    const style = new Style({
      image: new Icon({
        src: yellowMarkerImg, // 图片路径
        scale: 1, // 图片缩放比例
      }),
      text: new Text({
        text: number.toString(), // 将数字转换为字符串显示
        offsetY: -5, // 调整数字在图标上方的位置
        fill: new Fill({ color: 'rgba(5, 4, 38, 1)' }),
        font: 'normal 13px Arial', // 设置字体样式
      }),
    });

    point.setStyle(style);
    vectorLayer.value.getSource().addFeature(point);
  }
};
// end
</script>

<style scoped lang="scss">
.app-main {
  display: flex;
  justify-content: space-between;

  .app-left {
    margin-left: 30px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: calc(100% - 40px);
    width: 450px;
    &-total {
      width: 450px;
      height: 80px;
      background-size: 100% 100%;
      background-image: url('../../assets/images/losses/title.png');
      font-size: 22px;
      color: #46ffff;
      line-height: 80px;
      padding-left: 120px;
      box-sizing: border-box;
      display: flex;
      position: absolute;
      top: 100px;
      span {
        font-family: DS-Digital;
        font-weight: 600;
        font-size: 36px;
        padding-top: 22px;
        display: flex;
        margin-left: 8px;
        i {
          display: block;
          width: 26px;
          height: 36px;
          background: #004c86;
          margin: 0 2px;
          font-style: normal;
          line-height: 36px;
          text-align: center;
        }
      }
    }

    &-item {
      width: 450px;
      background: linear-gradient(
        135deg,
        rgba(0, 3, 45, 0.85) 0%,
        rgba(0, 12, 88, 0.85) 50%,
        rgba(0, 3, 45, 0.85) 100%
      );
      position: relative;
      position: absolute;
      &::after {
        content: '';
        display: block;
        width: 450px;
        height: 50px;
        background-size: 100% 100%;
        background-image: url('../../assets/images/common/bg_bottom.png') !important;
        position: absolute;
        bottom: -10px;
      }
      &:nth-child(2) {
        height: 220px;
        top: 200px;
        z-index: 10;
      }
      &:nth-child(3) {
        height: 300px;
        top: 430px;
      }
      &:nth-child(4) {
        height: 296px;
        top: 736px;
      }
    }
  }

  .app-map {
    width: 960px;
    height: 100%;
    //overflow: hidden; //test
    position: relative;
  }
  .app-right {
    margin-right: 30px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: calc(100% - 40px);
    width: 450px;

    &-item {
      width: 450px;
      height: 460px;
      background: linear-gradient(
        135deg,
        rgba(0, 3, 45, 0.85) 0%,
        rgba(0, 12, 88, 0.85) 50%,
        rgba(0, 3, 45, 0.85) 100%
      );
      position: relative;
      &::after {
        content: '';
        display: block;
        width: 450px;
        height: 50px;
        background-size: 100% 100%;
        background-image: url('../../assets/images/common/bg_bottom.png') !important;
        position: absolute;
        bottom: -10px;
      }
      &:nth-child(2) {
        height: 455px;
      }
    }
  }
}
/* start */
.popup-bg {
  width: 400px;
  height: 275px;
  background: linear-gradient(NaNdeg, rgba(5, 12, 53, 0.8) 0%, rgba(4, 16, 89, 0.8) 55%, rgba(6, 40, 150, 0.8) 100%);
  border-radius: 8px 8px 8px 8px;
  opacity: 1;
  border: 2px solid #0190f9;
  display: flex;
  padding: 17px 15px;
  flex-direction: column;
  .popup-head {
    justify-content: center;

    display: flex;
    flex-direction: row;
    font-size: 18px;
    font-family: Source Han Sans CN-Bold, Source Han Sans CN;
    font-weight: bold;
    color: #ffffff;
    line-height: 23px;
    .popup-head-title {
      margin-left: auto;
    }
    .popup-head-x {
      margin-left: auto;
      width: 12px;
      height: 12px;
      color: #e6f4fd;
      opacity: 1;
    }
  }
  .popup-content {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    font-size: 16px;
    font-family: Source Han Sans CN-Medium, Source Han Sans CN;
    font-weight: 500;
    color: #e6f4fd;
    line-height: 23px;
    .popup-content-title {
      background: #050426;
      border-radius: 0px 0px 0px 0px;
      opacity: 0.5;
      padding: 10px 34px;
      justify-content: space-between;
      display: flex;
      flex-direction: row;
    }
    .popup-table {
      .el-table {
        width: 270px;
        max-height: 150px;
        overflow-x: hidden;
        overflow-y: auto;
        z-index: 99;
        position: absolute;
        // top: 70px;
        // background-color: #00032D;
        /* background: linear-gradient(135deg, #00032d 0%, #000c58 50%, #00032d 100%); */
        :deep(.el-table__header) {
          background: rgba(5, 4, 38, 0.4);
        }

        :deep(.el-table__row) {
          background: rgba(5, 4, 38, 0.4);
        }
      }
    }
  }
}

/* end */
</style>
